@extends('admin.layouts.main')
@section('header')
    @parent
@endsection
@section('content')
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联赛</label>
                <div class="layui-input-inline">
                    <select name="league_id" id="leagueId" lay-search lay-verify="required">
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">期数</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="session" placeholder="期数" id="session" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">序号</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="search" name="number" placeholder="序号" lay-verify="required" />
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">主队</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="search" name="host" placeholder="主队" lay-verify="required" />
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">客队</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="search" name="guest" placeholder="客队"  lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">让球数</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="number" name="balls" placeholder="让球" value="-1" lay-verify="required" />
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">截止时间</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="die_time" placeholder="截止时间" id="dieTime" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">胜</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp11" placeholder="没有为1"  lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">平</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp12" placeholder="没有为1" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">负</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp13" placeholder="没有为1" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">让胜</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp21" placeholder="" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">让平</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp22" placeholder="" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">让负</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" name="sp23" placeholder="" lay-verify="required"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value="">
                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submit">立即提交</button>
            </div>
        </div>
    </form>
@endsection
@section('footer')
    @parent
    <script type="text/javascript">
       layui.use(['layer','jquery','form','laydate'],function () {
           var layer = layui.layer,
               $ = layui.jquery,
               laydate = layui.laydate,
               form = layui.form;
           laydate.render({
              elem:"#session",
               type:"date",
               format:"yyyyMMdd"
           });
           laydate.render({
               elem:"#dieTime",
               type:"datetime",
               format:"yyyy-MM-dd HH:mm:ss"
           });



           form.on("submit(submit)",function (data) {
               var formData = data.field;
                goConfirm('{{ url('admin/lottery/edit') }}',formData,'确认提交数据',1);
               return false;
           });
            getInfo();
           function getInfo(){
               var id = getUrlParam('id');
               $.get('{{ url('admin/lottery/detail') }}',{id:id},function (res) {
                   if(res.status == 200){
                       var data = res.data;
                       $('input[name="id"]').val(id);
                       $('input[name="session"]').val(data.session);
                       $('input[name="number"]').val(data.number);
                       $('input[name="host"]').val(data.host);
                       $('input[name="guest"]').val(data.guest);
                       $('input[name="balls"]').val(data.balls);
                       $('input[name="die_time"]').val(data.die_time);
                       $('input[name="sp11"]').val(data['sp1'][0]);
                       $('input[name="sp12"]').val(data['sp1'][1]);
                       $('input[name="sp13"]').val(data['sp1'][2]);
                       $('input[name="sp21"]').val(data['sp2'][0]);
                       $('input[name="sp22"]').val(data['sp2'][1]);
                       $('input[name="sp23"]').val(data['sp2'][2]);
                       buildOptions('{{ url('admin/lottery/league/list') }}',{},'#leagueId','id','name',data.league_id,true);

                   }
               },'json')
           }


       });

    </script>
@endsection